В этом небольшом руководстве мы мы будем, в основном, вносить изменения в файлы, которые автоматически генерируются OX в процессе создания нового проекта (Обратитесь к разделу 2.1 Справочного руководства OX за более полной информацией). Я предполагаю, что OpenXava установлена в папку openxava2.X
Подготовка Postgres
Для начала необходимо проверить, что Postgres запущен. С помощью pgadminIII (вы можете скачать её с веб сайта Postgres) вам необходимо создать базу “MYDB” (прошу соблюдать регистр символов в названии) и схему “management” (также важен регистр символов в названии).
Конфигурируем параметры подключения к DB (раздел 2.2 Справочного руководства OX)
Отредактируем файл context.xml из папки openxava2.x/portal/conf, чтобы там появилось следующее описание JDBC-ресурса:
my_postgres_password замените на актуальный пароль пользователя postgre в вашей базе данных Postgres. url="jdbc:postgresql:localhost:5432/MYDB" определяет параметры подключения к БД. (MYDB - это имя БД, которую мы создали ранее; localhost:5432 - это имя и порт сервера, где запущен сервис Postgres
Замечание:
We should distinguish the Tomcat from inside Eclipse and the one outside Eclipse. In the first case the file context.xml is in the folder “openxava2.X/workspace/Servers/Tomcat v5.5 Server @ localhost-config “ and in the second case in the fólder “openxava2.X/portal/conf”. See OpenXava with Eclipse WTP.
Изменения в файле “build.xml”
We look for a line containing tomcat-hypersonic and comment it and add a new line as shows:
In addition, we look for the task updateSchema and give the variable schema.paththe absolute path for the JDBC JAR driver (in my particular case in Windows XP "C:\POSTGRES\postgresql-8.3dev-601.jdbc3.jar". You can verify if there is a newer JDBC driver in the WEB, and you should use it!
<!-- Comment<property name="schema.path" value="[PUT HERE THE PATH OF YOUR JDBC DRIVER]"/>--><propertyname="schema.path"value="C:/POSTGRES/postgresql-8.3dev-601.jdbc3.jar"/>
Не забудьте сохранить изменения.
Добавление драйвера JDBC для Postgres в Tomcat
Для того, чтобы доступ к БД работал в Tomcat, необходимо скопировать JDBC драйвер, у меня это C:\POSTGRES\postgresql-8.3dev-601.jdbc3.jar , в папку openxava-2.X/portal/common/lib
Создание файла “tomcat-postgres.properties”
Let’s copy the file tomcat-hypersonic.properties to a new one called tomcat-postgres.properties. Let’s change separator to “.” And hibernate.dialect to “org.hibernate.dialect.PostgreSQLDialect”
Where localhost:5432 references the address and port of our server running the Postgres service and MYDB is the database we are using for this example.
In addition to these, we have to change all about users and passwords in the DB. We should change the user to postgres and introduce the correct password. We shall comment the lines referencing HSQLDB
Moving to the section 2.3 of the OX Reference guide
Our component “Warehouse.xml” that has been mapped to the table WAREHOUSES from the schema “MANAGENENT” (which was previously created as “management” in lower case letters) remains unchanged as in section 2.3 as follows:
<?xmlversion="1.0"encoding="ISO-8859-1"?><!DOCTYPE component SYSTEM "dtds/component.dtd"><componentname="Warehouse"><entity><propertyname="zoneNumber"key="true"size="3"required="true"type="int"/><propertyname="number"key="true"size="3"required="true"type="int"/><propertyname="name"type="String"size="40"required="true"/></entity><entity-mappingtable=MANAGEMENT@separator@WAREHOUSES><property-mappingproperty="zoneNumber"column="ZONE"/><property-mappingproperty="number"column="NUMBER"/><property-mappingproperty="name"column="NAME"/></entity-mapping></component>
Let’s execute the Ant tasks generateCode and rebuild and finally updateSchema and the tables should be created in our database.
After that, follow the instructions from the guide.
(improvements to this page and error reporting are wellcome. Eduard.)
Table of Contents
Конфигурация OpenXava 2.X для Postgres
В этом небольшом руководстве мы мы будем, в основном, вносить изменения в файлы, которые автоматически генерируются OX в процессе создания нового проекта (Обратитесь к разделу 2.1 Справочного руководства OX за более полной информацией). Я предполагаю, что OpenXava установлена в папку openxava2.XПодготовка Postgres
Для начала необходимо проверить, что Postgres запущен. С помощью pgadminIII (вы можете скачать её с веб сайта Postgres) вам необходимо создать базу “MYDB” (прошу соблюдать регистр символов в названии) и схему “management” (также важен регистр символов в названии).Конфигурируем параметры подключения к DB (раздел 2.2 Справочного руководства OX)
Отредактируем файл context.xml из папки openxava2.x/portal/conf, чтобы там появилось следующее описание JDBC-ресурса:my_postgres_password замените на актуальный пароль пользователя postgre в вашей базе данных Postgres.
url="jdbc:postgresql:localhost:5432/MYDB" определяет параметры подключения к БД. (MYDB - это имя БД, которую мы создали ранее; localhost:5432 - это имя и порт сервера, где запущен сервис Postgres
Замечание:
We should distinguish the Tomcat from inside Eclipse and the one outside Eclipse. In the first case the file context.xml is in the folder “openxava2.X/workspace/ Servers/Tomcat v5.5 Server @ localhost-config “ and in the second case in the fólder “openxava2.X/portal/conf”. See OpenXava with Eclipse WTP.
Изменения в файле “build.xml”
We look for a line containing tomcat-hypersonic and comment it and add a new line as shows:In addition, we look for the task updateSchema and give the variable schema.path the absolute path for the JDBC JAR driver (in my particular case in Windows XP "C:\POSTGRES\postgresql-8.3dev-601.jdbc3.jar". You can verify if there is a newer JDBC driver in the WEB, and you should use it!
Не забудьте сохранить изменения.
Добавление драйвера JDBC для Postgres в Tomcat
Для того, чтобы доступ к БД работал в Tomcat, необходимо скопировать JDBC драйвер, у меня это C:\POSTGRES\postgresql-8.3dev-601.jdbc3.jar , в папку openxava-2.X/portal/common/libСоздание файла “tomcat-postgres.properties”
Let’s copy the file tomcat-hypersonic.properties to a new one called tomcat-postgres.properties. Let’s change separator to “.” And hibernate.dialect to “org.hibernate.dialect.PostgreSQLDialect”
Edit the file “hibernate/hibernate-junit.cfg.xml”
We should comment all about HSQLDB and create new entries for Postgres:Where localhost:5432 references the address and port of our server running the Postgres service and MYDB is the database we are using for this example.
In addition to these, we have to change all about users and passwords in the DB. We should change the user to postgres and introduce the correct password. We shall comment the lines referencing HSQLDB
And save changes.
Moving to the section 2.3 of the OX Reference guide
Our component “Warehouse.xml” that has been mapped to the table WAREHOUSES from the schema “MANAGENENT” (which was previously created as “management” in lower case letters) remains unchanged as in section 2.3 as follows:Let’s execute the Ant tasks generateCode and rebuild and finally updateSchema and the tables should be created in our database.
After that, follow the instructions from the guide.
(improvements to this page and error reporting are wellcome. Eduard.)